package PHANVANVUONG.ARRAY.HOMEWORK;

public class Models04 {
	public int getMaxMin(int[] A, boolean a) {
		int max = A[0];
		int min = A[0];
		if (a) {
			for (int i = 1; i < A.length; i++) {
				if (A[i] > max)
					max = A[i];
			}
			return max;
		} else {
			for (int i = 1; i < A.length; i++) {
				if (A[i] < min)
					min = A[i];
			}
			return min;
		}
	}

	public String getIndexMaxMin(int[] A, boolean a) {
		String s = "";
		if (a) {
			for (int i = 0; i < A.length; i++) {
				if (A[i] == getMaxMin(A, true)) {
					if (s.isEmpty())
						s += (i + 1);
					else
						s += ", " + (i + 1);
				}
			}
		} else {
			for (int i = 0; i < A.length; i++) {
				if (A[i] == getMaxMin(A, false)) {
					if (s.isEmpty())
						s += (i + 1);
					else
						s += ", " + (i + 1);
				}
			}
		}
		return s;
	}
}
